class TokenManager {
    private static ACCESS_TOKEN_KEY = "access_token";
    // 保存 access token
    static saveAccessToken(token: string): void {
        localStorage.setItem(this.ACCESS_TOKEN_KEY, token);
    }

    // 获取 access token
    static getAccessToken(): string | null {
        return localStorage.getItem(this.ACCESS_TOKEN_KEY);
    }

    // 删除 access token
    static removeAccessToken(): void {
        localStorage.removeItem(this.ACCESS_TOKEN_KEY);
    }

    private static REFRESH_TOKEN_KEY = "refresh_token";
    // 保存 refresh token
    static saveRefreshToken(token: string): void {
        localStorage.setItem(this.REFRESH_TOKEN_KEY, token);
    }

    // 获取 refresh token
    static getRefreshToken(): string | null {
        return localStorage.getItem(this.REFRESH_TOKEN_KEY);
    }

    // 删除 refresh token
    static removeRefreshToken(): void {
        localStorage.removeItem(this.REFRESH_TOKEN_KEY);
    }

    // 清除所有 tokens
    static clearAllTokens(): void {
        this.removeAccessToken();
        this.removeRefreshToken();
    }
}

export default TokenManager;
